<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 数组去重

    let arr1 = [2, 4, 5, 2, 4, 6, 7, 2]

    //1
    //     function get(){
    //     let result=[...new Set(arr1)]
    //     console.log(result);
    //     }
    //   get()
    2
    //indexof -1
    // function get (){
    //     var arr=[]
    //     for(var i =0;i<arr1.length;i++){
    //         if(arr.indexOf(arr1[i])===-1){
    //             arr.push(arr1[i])
    //         }
    // }
    //     return arr
    // }
//     console.log(get(arr1));

//     3// includes
// function get(){
//     var arr = []
// for(var i=0;i<arr1.length;i++){
//     if(!arr.includes(arr1[i])){
//         arr.push(arr1[i]) 
//     }
// }
// return arr
// }
// 4 fitter
function get (){
    return arr1.filter((item,index)=>{
return arr1.indexOf(item,0)===index
    })
}
console.log(get(arr1));
</script>

</html>